<?php

class TestCriteria extends PHPUnitTest {

    public function testCriteriaInstantiationThrowsExceptionWhenParametersAreNotSupplied() {
        try {
            $criteria = new Criteria();
        }
        catch(UnexpectedValueException $exception) {}

        $this->assertNotNull($exception);
        $this->assertInstanceOf('UnexpectedValueException', $exception);
        $this->assertEquals('The criteria is being created with invalid values.', $exception->getMessage());
    }

    public function testCriteriaInstantiationThrowsExceptionWhenInvalidParametersAreSupplied() {
        try {
            $criteria = new Criteria('abc', array(), new stdClass());
        }
        catch(UnexpectedValueException $exception) {}

        $this->assertNotNull($exception);
        $this->assertInstanceOf('UnexpectedValueException', $exception);
        $this->assertEquals('The criteria is being created with invalid values.', $exception->getMessage());
    }

    public function testCriteriaInstantiationThrowsNoExceptionWhenValuesAreCorrect() {
        try {
            $criteria = new Criteria('id', Criteria::EQUAL, '55');
        }
        catch(UnexpectedValueException $exception) {}

        $this->assertNotNull($criteria);
    }

}